package com.jy.service;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.IService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.jy.mapper.UserMapper;
import com.jy.pojo.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class UserService extends ServiceImpl<UserMapper, User> implements IService<User> {
    @Autowired
    UserMapper userMapper;

    public String checkUsername(String username) {
        LambdaQueryWrapper<User> qw = new LambdaQueryWrapper<>();
        qw.eq(User::getUsername, username);
        Long l = userMapper.selectCount(qw);
        if (l > 0) {
            return "200";
        }
        return "300";
    }
    public String register(User user) {
        userMapper.insert(user);
        return "200";
    }
}
